package com.taxi.serviceOrder.controller;

import com.taxi.common.dto.OrderInfo;
import com.taxi.serviceOrder.mapper.OrderInfoMapper;
import com.taxi.serviceOrder.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Ruomeng
 * @Date: 2022/10/15
 * @Description : online-taxi
 * @Version: 1.0
 */
@RestController
public class TestController {

    @GetMapping("/test")
    public String test() {
        return "service-order test";
    }

    @Autowired
    OrderInfoService orderInfoService;

    @Autowired
    OrderInfoMapper orderInfoMapper;

    @Value("${server.port}")
    String port;

    /**
     * 测试派单逻辑
     *
     * @param orderId
     * @return
     */
    @GetMapping("/test-real-time-order/{orderId}")
    public String dispatchRealTimeOrder(@PathVariable("orderId") long orderId) {
        System.out.println("service-order 端口：" + port + " 并发测试：orderId：" + orderId);
        OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
        orderInfoService.dispatchRealTimeOrder(orderInfo);
        return "test-real-time-order success";
    }

}